let index_fn = async (ctx, next) => {
    ctx.response.body = `
    <form action="/login" method="post">
        <table>
            <div>
                <label for="">用户名：</label>
                <input type="text" name="username">
            </div>
            <div>
                <label for="">密码：</label>
                <input type="password" name="password">
            </div>
            <div>
                <input type="submit" value="登录">
            </div>
        </table>
    </form>
    `;
};

let login_fn = async (ctx, next) => {
    let username = ctx.request.body.username;
    let password = ctx.request.body.password;
    if (username === 'admin' && password === '123') {
        ctx.response.redirect('/login/success');
    } else {
        ctx.response.redirect('/login/error');
    };
}

module.exports = {
    '/': ["get", index_fn],
    '/login': ['post', login_fn]
}